<?php
Class FeedbackController{
public $title;
public $index;
public $link;
public $page;
public $input;
public $results;
 
	public function __construct(){
		$this->layout = 'false';
	}

	public function SendAction(){
		$this->layout = "false";
		require_once(PLUGINS_PATH.'/Mail.php');
		$request = getRequest::getInstance();
		
		if($request->isPost()){
		//$name = "Admin";
		//$email = "dem66@ukr.net";
		//$text = "Как работает почта";
			$name = $request->getVar('name', 'POST');
			$surname = $request->getVar('surname', 'POST');
			$email = $request->getVar('email', 'POST');
			$text = $request->getVar('text', 'POST');

			$error = 2;
			$status = array();
			
			if(empty($name) || empty($surname) || empty($email) || empty($text)){
				$error = 1;
				exit();
			}


			$conf = Config::Ini(APPLICATION_PATH.'/configs/application.conf', 'config', 1);
			
			send_mime_mail($name.' '.$surname, // имя отправителя
				 $email, // email отправителя!@
				 $conf['mails']['feedback']['email'], // email получателя
				 'utf-8', // кодировка письма
				 $conf['mails']['feedback']['title'], // тема письма
				 $text // текст письма
			);
				 
			unset($conf);
			
		 }
			$ref = $request->Referrer();
			if(!empty($ref)){
				header("location: /".$ref['path']);
			}else{
				header("location: /index.html");
			}
	}
}
